/*
* Copyright (C) 2008-2009 Manjeet Dahiya
*
* Author:
*    Manjeet Dahiya
*/

#include "touchexmppclient.h"
#include "QXmppMessage.h"
#include "QXmppRoster.h"
#include "QXmppPacket.h"
#include "QXmppStream.h"
#include <iostream>
#include "QFile"
ToucheXmppClient::ToucheXmppClient(QObject *parent)
    : QXmppClient(parent)
{

  bool check = connect(this, SIGNAL(connected()),
        SLOT(clientConnected()));
    Q_ASSERT(check);

    check = connect(&this->getRoster(), SIGNAL(rosterReceived()),
        SLOT(rosterReceived()));
    Q_ASSERT(check);

    /// Then QXmppRoster::presenceChanged() is emitted whenever presence of someone
    /// in roster changes
    check = connect(&this->getRoster(),
                    SIGNAL(presenceChanged(const QString&, const QString&)),
        SLOT(presenceChanged(const QString&, const QString&)));
    Q_ASSERT(check);
   //ccc
    check = connect(this, SIGNAL(messageReceived(const QXmppMessage&)),
        SLOT(messageReceived(const QXmppMessage&)));
    Q_ASSERT(check);
}

ToucheXmppClient::~ToucheXmppClient(){
}

void ToucheXmppClient::clientConnected()
{
    ToucheXmppClient::setClientPresence("I'm using Touché!!!");
}


void ToucheXmppClient::rosterReceived()
{
    QStringList list = getRoster().getRosterBareJids();
}

void ToucheXmppClient::presenceChanged(const QString&, const QString&)
{
}

void ToucheXmppClient::sendMessage(const QXmppMessage& message){
    sendPacket(message);
}


QString ToucheXmppClient::getPass(){
    return this->pass;
}

void ToucheXmppClient::setPass(QString pass){
        this->pass = pass;
}

QString ToucheXmppClient::getEmail(){
    return this->email;
}

void ToucheXmppClient::setEmail(QString email){
    this->email = email;
}

void ToucheXmppClient::addBuddy(const QString& bareJid)
{
    QXmppPresence packet;
    packet.setTo(bareJid);
    packet.setType(QXmppPresence::Subscribe);
    this->sendPacket(packet);
}
